package com.xsmart.common.entity;

import com.xsmart.common.constant.ApiInfoFieldConstant;
import org.apache.commons.collections.MapUtils;

import java.util.Map;

/**
 * API配置信息
 */
public class ApiInfo {
    private String url;
    private String modular;
    private String version;
    private String serviceName;
    private String methodName;
    private boolean isLogin;
    private boolean isLog;
    private Integer serviceId;
    private boolean status;
    private String serviceUri;
    private String serviceTerminal;

    public ApiInfo() {
    }

    public ApiInfo(Map<String, String> apiInfoMap) {
        setUrl(MapUtils.getString(apiInfoMap, ApiInfoFieldConstant.URL, ""));
        setModular(MapUtils.getString(apiInfoMap, ApiInfoFieldConstant.MODULAR, ""));
        setServiceName(MapUtils.getString(apiInfoMap, ApiInfoFieldConstant.SERVICE_NAME, ""));
        setMethodName(MapUtils.getString(apiInfoMap, ApiInfoFieldConstant.METHOD_NAME, ""));
        setLogin(MapUtils.getIntValue(apiInfoMap, ApiInfoFieldConstant.IS_LOGIN, 1) == 1);
        setLog(MapUtils.getIntValue(apiInfoMap, ApiInfoFieldConstant.IS_LOG, 0) == 1);
        setStatus(MapUtils.getIntValue(apiInfoMap, ApiInfoFieldConstant.SERVICE_STATUS, 1) == 1);
        setVersion(MapUtils.getString(apiInfoMap, ApiInfoFieldConstant.VERSION, ""));
        setServiceUri(MapUtils.getString(apiInfoMap, ApiInfoFieldConstant.SERVICE_URI, ""));
        setServiceTerminal(MapUtils.getString(apiInfoMap, ApiInfoFieldConstant.SERVICE_TERMINAL, ""));
        setServiceId(MapUtils.getInteger(apiInfoMap, ApiInfoFieldConstant.SERVICE_ID, -1));
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getModular() {
        return modular;
    }

    public void setModular(String modular) {
        this.modular = modular;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getServiceName() {
        return serviceName;
    }

    public void setServiceName(String serviceName) {
        this.serviceName = serviceName;
    }

    public String getMethodName() {
        return methodName;
    }

    public void setMethodName(String methodName) {
        this.methodName = methodName;
    }

    public boolean isLogin() {
        return isLogin;
    }

    public void setLogin(boolean login) {
        isLogin = login;
    }

    public boolean isLog() {
        return isLog;
    }

    public void setLog(boolean log) {
        isLog = log;
    }

    public Integer getServiceId() {
        return serviceId;
    }

    public void setServiceId(Integer serviceId) {
        this.serviceId = serviceId;
    }

    public boolean isStatus() {
        return status;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }

    public String getServiceUri() {
        return serviceUri;
    }

    public void setServiceUri(String serviceUri) {
        this.serviceUri = serviceUri;
    }

    public String getServiceTerminal() {
        return serviceTerminal;
    }

    public void setServiceTerminal(String serviceTerminal) {
        this.serviceTerminal = serviceTerminal;
    }
}
